﻿using Microsoft.Xna.Framework;

namespace WindowsGame.Manager
{
	/// <summary>
	/// CameraManager is responsible for managing camera view/projection matrices.
	/// </summary>
	public interface ICameraManager
	{
		void Initialize(Vector3 cameraPosition);
		Matrix ViewMatrix { get; }
		Matrix ProjectionMatrix { get; }
	}

	public class CameraManager : ICameraManager
	{
		// CameraManager has dependency on GraphicsManager.
		private readonly IGraphicsManager graphicsManager;

		public CameraManager(IGraphicsManager graphicsManager)
		{
			this.graphicsManager = graphicsManager;
		}

		// Initialize camera view/projection matrices.
		public void Initialize(Vector3 cameraPosition)
		{
			ViewMatrix = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
			ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, graphicsManager.AspectRatio, 1.0f, 10000.0f);
		}

		public Matrix ViewMatrix { get; private set; }
		public Matrix ProjectionMatrix { get; private set; }
	}
}